from django.forms import fields
from django.db import models
from widgets import *
import os, re

class DirectoryPathField(models.FilePathField):
    def __init__(self, *args, **kwargs):
        super(DirectoryPathField, self).__init__(*args, **kwargs)

    def formfield(self, **kwargs):
        defaults = {
            'path': self.path,
            'match': self.match,
            'recursive': self.recursive,
            'form_class': DirectoryPathFieldWidget,
        }
        defaults.update(kwargs)
        return super(DirectoryPathField, self).formfield(**defaults)

    def get_internal_type(self):
        return "DirectoryPathField"
